<template>
  <div>
    <el-table
      :data="dataList"
      border
      stripe
      v-loading="dataListLoading"
      style="width: 100%; margin-top: 20px;">
      <el-table-column prop="subjectCode" header-align="center" align="center" label="课题编码"></el-table-column>
      <el-table-column prop="researchName" header-align="center" align="center" label="课题名称"></el-table-column>
      <el-table-column prop="researchSimpleName" header-align="center" align="center" label="课题简称"></el-table-column>
      <el-table-column prop="piName" header-align="center" align="center" label="课题PI"></el-table-column>
<!--      <el-table-column prop="sitePkId" header-align="center" align="center" label="分中心"></el-table-column>-->
<!--      <el-table-column prop="completion_rate" header-align="center" align="center" label="完成率"></el-table-column>-->
<!--      <el-table-column prop="state" header-align="center" align="center" label="状态"></el-table-column>-->
      <el-table-column fixed="right" header-align="center" align="center" width="250" label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="lookHandle(scope.row.subjectPkId)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper"
      style="margin-top: 20px;"
    >
    </el-pagination>
  </div>
</template>

<script>
import research from '@/api/research'
export default {
  data() {
    return {
      dataList: [
        {
          id:0,
        },
      ],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false

    }
  },
  created() {

    this.getDataList();
  },
  methods: {


    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataList()
    },

    getDataList()
    {
      this.dataListLoading = true;
      this.dataListLoading = false;

      research.getByResearchByUser(this.$store.getters.name,this.pageIndex,this.pageSize).then(response=>{
        this.dataList = response.data.records;
        this.totalPage = response.data.total;

      });
      //@发现一个问题在then里面的datalist和在外面的datalist不一样 有可能是更新完列表就消失了
    },
    lookHandle(subjectPkId)
    {
     // this.$store.commit('set_subjectPkId',subjectPkId)

      this.$router.push({path:`/upload/research-manager?subjectPkId=${subjectPkId}`})
    },



  },

}
</script>
<style>


</style>
